package com.yong.ssj.service.sys;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yong.ssj.db.dao.sys.IUserDao;
import com.yong.ssj.db.dto.cost.CostMethodDto;
import com.yong.ssj.db.dto.customer.CustomerDto;
import com.yong.ssj.db.dto.sys.UserDto;
import com.yong.ssj.util.BeanUtil;

@Service(value="userServiceImpl")
public class UserServiceImpl implements IUserService{

	@Resource(name="userDaoImpl")
	private IUserDao userDao;

	@Override
	public int login(String username, String password) {
		// TODO Auto-generated method stub
		UserDto user= userDao.query(username);
		if(user.getUser_password().equals(password)){
			return 1;
		}else{
			return 0;
		}
		
	}

	@Override
	public CustomerDto loginph(String customer_name, String customer_password) {
		// TODO Auto-generated method stub
		CustomerDto dto = userDao.queryph(customer_name);
		return dto;
	}

	@Override
	public int register(String customer_name, String customer_password) {
		// TODO Auto-generated method stub
		 return userDao.register(customer_name, customer_password);
//		 int customer_id = userDao.queryph(customer_name, customer_password);
//		  userDao.zeng(customer_id);
	}

	@Override
	public int reset(String customer_name, String customer_password, long customer_id) {
		// TODO Auto-generated method stub
		return userDao.reset(customer_name, customer_password, customer_id);
	}

	@Override
	public int updatemima(String customer_password, String password1, long customer_id) {
		// TODO Auto-generated method stub
		int yan = userDao.yanmima(customer_password, customer_id);
		if(yan==1){
			return userDao.updatemima(password1, customer_id);
		}else {
			return 0;
		}
		
	}

	@Override
	public int loginphyz(String customer_name) {
		// TODO Auto-generated method stub
		return userDao.loginphyz(customer_name);
	}

	@Override
	public List<Map<String, Object>> queryUser() {
		// TODO Auto-generated method stub
		return userDao.queryUser();
	}

	@Override
	public UserDto queryManger(long user_id) {
		// TODO Auto-generated method stub
		return userDao.queryUser(user_id);
	}

	@Override
	public UserDto queryme(String user_name) {
		// TODO Auto-generated method stub
		return userDao.query(user_name);
	}

	@Override
	public int add(UserDto vo) {
		// TODO Auto-generated method stub
		return userDao.add(vo);
	}

	@Override
	public int updateUser(UserDto vo) {
		// TODO Auto-generated method stub
		return userDao.updateUser(vo);
	}

	@Override
	public List<Map<String, Object>> queryCost() {
		// TODO Auto-generated method stub
		return userDao.queryCost();
	}

	@Override
	public CostMethodDto updateCost(String id) {
		// TODO Auto-generated method stub
		return userDao.updateCost(Long.parseLong(id));
	}

	@Override
	public int updateCostDo(CostMethodDto dto) {
		// TODO Auto-generated method stub
		return userDao.updateCostDo(dto);
	}

	@Override
	public int addCost(CostMethodDto vo) {
		// TODO Auto-generated method stub
		return userDao.addCost(vo);
	}
	
	

}
